home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-11-22 | 86.0 KB | 2,155 lines |
- *-----------------------------------------------------------------------
- *-- Program..: PICKLIST.PRG
- *-- Date.....: 09/02/1993
- *-- Notes....: This new (as of November, 1992) section of the DUFLP
- *-- library is designed to be a place where a variety of
- *-- picklist routines will be stored. You can ... ahem ...
- *-- pick and choose the one(s) you need from here.
- *-- WARNING..: Do not save changes with WordStar 5.5 Non_Document mode
- *-- --the diacritical characters in the DIACRIT procedure
- *-- below will not be saved properly (WordStar doesn't like
- *-- high ASCII characters ...)
- *-----------------------------------------------------------------------
-
- FUNCTION Pick1
- *-----------------------------------------------------------------------
- *-- Programmer..: Kenneth W. Holloway (HollowayK on BORBBS)
- *-- Date........: 11/01/1993
- *-- Notes.......: Pick List.
- *-- Written for.: dBASE IV, 1.5
- *-- Rev. History: 08/12/1992 0.0 - Original version (KWH)
- *-- 09/11/1992 0.1 - (KWH) Added color settings
- *-- (x_ClrP*) that were Ass-U-Med to
- *-- be defined elsewhere.
- *-- 09/16/1992 0.2 - (KWH) Added "set key to" at end
- *-- of function. (BORLAND: What
- *-- happened to set("KEY")?!?!)
- *-- 10/14/1992 0.3 - Added (KenMayer) ability to pass
- *-- colors to program ... removed
- *-- settings for alias, order, key.
- *-- The reason is a lack of stack
- *-- space to call routine, can only
- *-- send x number of parms. The
- *-- programmer must set the database
- *-- (select .../Use ...), order, and
- *-- key (set key...) before calling
- *-- this routine, and then reset to
- *-- prior setting (if needed).
- *-- 10/15/1992 0.4 - (KWH) Added code for Tab/Shift
- *-- Tab. Put the setting for key back
- *-- in, as it is required for proper
- *-- SEEKing with SET KEY in effect.
- *-- 10/19/1992 0.5 - (KWH) Several changes inspired by
- *-- JOEY:
- *-- ˛ Now uses setting of SET BORDER TO
- *-- when drawing borders.
- *-- ˛ Bell only sounds when SET BELL is
- *-- ON.
- *-- ˛ Added code for {Home} and {End}.
- *-- 11/06/1992 0.6 - (KWH) Optimization inspired by
- *-- KELVIN:
- *-- ˛ Removed repetitive recalculation
- *-- of PICTURE clause
- *-- ˛ Removed some dead code
- *-- ˛ Added a logical variable for main
- *-- loop, instead of four .and.ed
- *-- expressions
- *-- 02/22/1993 -- Minor change to PRIVATE calls.
- *-- 11/01/1993 -- Changes suggested by David Jellison
- *-- (CAI, via Internet) to give a cleaner
- *-- title bar.
- *-- Calls.......: ColorBrk() Function in PROC.PRG
- *-- Called by...: Any
- *-- Usage.......: Pick1(cTitle,cDisplay,cReturn[,cKey[,nFromrow, ;
- *-- nFromcol[,nTorow,nTocol[,cColor1[,cColor2]]]]])
- *-- Example.....: ? Pick1("Client Name","NAME","JOB_CODE","",5,10,20,55,;
- *-- cColor1,cColor2)
- *-- Returns.....: Specified expression, using macro substitution.
- *-- Parameters..: cTitle = Title to be displayed above PickList
- *-- cDisplay = Expression to display, using macro
- *-- substitution
- *-- Note: If cDisplay includes any chr(29)'s (),
- *-- the Tab and Shift Tab keys can be used to
- *-- highlight/unhighlight everything up to
- *-- the next/previous chr(29).
- *-- cReturn = Expression to return, using macro
- *-- substitution
- *-- cKey = Expression for SET KEY TO
- *-- nFromrow \ Upper left corner
- *-- nFromcol / of PickList window
- *-- nTorow \ Lower right corner
- *-- nTocol / of PickList window
- *-- cColor1 = message,title,box
- *-- cColor2 = highlight,selected
- *-- Both cColor1 and cColor2 use specific
- *-- color settings of <Foreground> /
- *-- <Background> for each part of the parm.
- *-- For example, cColor1 might look like:
- *-- rg+/gb,w+/b,rg+/gb
- *-- Definitions:
- *-- message = unselected items in picklist
- *-- (w+/rb)
- *-- title = title at top of window
- *-- (w+/rb)
- *-- box = border (rg+/rb)
- *-- highlight = highlighted item (g+/n)
- *-- selected = selected character(s)
- *-- (r+/n)
- *-----------------------------------------------------------------------
- parameters cTitle, cDisplay, cReturn, cKey, nFromrow, nFromcol, ;
- nTorow, nTocol, cColor1, cColor2
-
- private all except _p*
-
- * Check validity of all parameters
- if pcount()<3
- RETURN "***"+PROGRAM()+" Error***"
- endif
-
- * Save setting of TALK and turn it off.
- m->cTalk = SET("TALK")
- set talk off
-
- * Save and change settings of other parameters
- m->cConsole = set("CONSOLE")
- m->cCursor = set("CURSOR")
- m->cEscape = set("ESCAPE")
- set cursor off
- set escape off
-
- * set default values for unspecified parameters
- if type("cKey")="L"
- m->cKey = ""
- endif
- if type("nFromrow")="L"
- m->nFromrow = 5
- endif
- if type("nFromcol")="L"
- m->nFromcol = 5
- endif
-
- if type("cColor1")="L"
- m->x_Clrpmess = "W+/RB"
- m->x_Clrptitl = "W+/RB"
- m->x_Clrpbox = "RG+/RB"
- else
- m->x_Clrpmess = colorbrk(m->cColor1,1)
- m->x_Clrptitl = colorbrk(m->cColor1,2)
- m->x_Clrpbox = colorbrk(m->cColor1,3)
- endif
- if type("cColor2")="L"
- m->x_Clrphigh = "G+/N"
- m->x_Clrpslct = "R+/N"
- else
- m->x_Clrphigh = colorbrk(m->cColor2,1)
- m->x_Clrpslct = colorbrk(m->cColor2,2)
- endif
-
- *-- Real code starts here
- * setup specified database environment
- if .not.isblank(m->cKey)
- set key to m->cKey
- endif
-
- * Calculate value of m->nTorow
- if type("nTorow")="L"
- goto top
- count to m->nTorow next 21-m->nFromrow
- m->nTorow = m->nFromrow + max(m->nTorow,3) + 3
- endif
-
- * Calculate value of m->nTocol
- if type("nTocol")="L"
- m->nTocol = m->nFromcol + max(len(m->cTitle), ;
- len(&cDisplay.)) + 1
- if m->nTocol>79
- m->nTocol = 79
- endif
- endif
-
- * Define and activate title window, draw border and title
-
- define window wPickList1 from m->nFromRow,m->nFromCol ;
- to m->nTorow, m->nTocol none ;
- color &x_Clrpmess.
-
- activate window wPickList1
- m->nWindrow = m->nTorow - m->nFromRow
- m->nWindcol = m->nTocol - m->nFromCol
- @ 00,00 to m->nWindrow,m->nWindcol color &x_Clrpbox.
- m->nCenter = ((m->nToRow-m->nFromRow)-len(m->cTitle))/2
- @ 01,01 fill to 01,((m->nToRow-nFromRow)-2) color &x_clrPTitl.
- @ 01,m->nCenter say trim(m->cTitle) color &x_Clrptitl.
- @ 02,01 to 02,m->nWindcol-1 color &x_Clrpbox.
- m->cBorder = set("BORDER")
- do case
- case m->cBorder="NONE"
- case m->cBorder="SINGLE"
- @ 02,00 say "√" color &x_Clrpbox.
- @ 02,m->nWindcol say "¥" color &x_Clrpbox.
- case m->cBorder="DOUBLE"
- @ 02,00 say "Ã" color &x_Clrpbox.
- @ 02,m->nWindcol say "π" color &x_Clrpbox.
- case m->cBorder="PANEL"
- @ 02,00 say "€" color &x_Clrpbox.
- @ 02,m->nWindcol say "€" color &x_Clrpbox.
- otherwise
- @ 02,00 say chr(val(substr(m->cBorder,17,3))) ;
- color &x_Clrpbox.
- @ 02,m->nWindcol say chr(val(substr(m->cBorder,21,3))) ;
- color &x_Clrpbox.
- endcase
-
- * define and activate data window
- define window wPickList2 from nFromRow+3,nFromCol+1 ;
- to nTorow-1,nTocol-1 none ;
- color &x_Clrpmess.
-
- activate window wPickList2
- m->nWindrow = m->nTorow - m->nFromRow-4
- m->nWindcol = m->nTocol - m->nFromCol-2
- m->cWindpict = replicate('X',m->nWindcol+1)
-
- * Initialize position and status variables
- goto top
- m->lBell = (set("BELL")="ON")
- m->nCurrow = 0
- m->nInkey = 0
- m->nNewrow = 0
- m->nRecno = recno()
- m->lRepaint = .T.
- m->cSeek = ""
- m->lSeek = .F.
- m->nNewscur = 0
- m->nSeekCur = 0
- if eof()
- if m->lBell
- @ 00,00 say chr(7)
- endif
- @ 00,00 say "*** No records to list ***"
- set console off
- wait
- set console on
- m->cReturn = ""
- m->nInkey = 27
- endif
-
- *-- Display PickList until Enter .or. Ctrl-Q .or. Ctrl-W or Ctrl-End
- *-- .or. Esc is pressed
- m->lMore = .T.
- do while m->lMore
- if m->lSeek
- seek m->cKey+m->cSeek
- m->nNewscur = len(m->cSeek)
- m->cStr = &cDisplay.
- m->nPos = at(chr(29),substr(m->cStr,1,m->nNewscur+1))
- do while m->nPos>0
- m->cStr = stuff(m->cStr,m->nPos,1," ")
- m->nNewscur = m->nNewscur + 1
- m->nPos = at(chr(29),substr(m->cStr,1,m->nNewscur+1))
- enddo
- m->nSeek = recno() && Save new record number
- n = 0 && counter
- goto m->nRecno && Record at top of screen
- * Look to see if new record is on screen
- scan while recno()#m->nSeek .and. m->n < m->nMaxrow
- m->N = m->N + 1
- endscan
- if recno()=m->nSeek && New record is on screen
- m->nNewrow = m->N && Put cursor on new record
- else && New record is not on screen
- m->nNewrow = 0 && Put cursor at top of window
- m->nRecno = m->nSeek && New record at top of window
- m->lRepaint = .T. && Redisplay window
- endif
- m->lSeek = .F.
- endif
-
- if m->lRepaint .OR. m->nNewrow#m->nCurrow
- * Hide cursor
- @ m->nCurrow,00 FILL to m->nCurrow,m->nWindcol ;
- color &x_Clrpmess.
- endif
-
- if m->lRepaint && Need to redisplay entire data window
- goto m->nRecno && Record that should be at top of window
- m->nMaxrow = 0 && Number of rows displayed
- scan while m->nMaxrow<=m->nWindrow && m->nWindrow = number of
- * Display data && rows in window
- @ m->nMaxrow,00 say &cDisplay. picture m->cWindpict ;
- color &x_Clrpmess.
- m->nMaxrow = m->nMaxrow + 1 && Increase rows displayed
- endscan && counter
- m->nMaxrow = m->nMaxrow - 1 && Make rows displayed
- && counter zero-based
- if eof() .and. m->nMaxrow<m->nWindrow && Didn't fill window?
- * Clear unused portion of window
- @ m->nMaxrow+1,00 clear to m->nWindrow,m->nWindcol
- endif
- endif
-
- if m->lRepaint .or. m->nNewrow#m->nCurrow ;
- .or. m->nNewscur#m->nSeekCur
- m->nSeekCur = m->nNewscur && New seek cursor length
- m->nCurrow = m->nNewrow && New cursor position
- if m->nCurrow > m->nMaxrow && Cursor row invalid? (Caused by
- && PgDn)
- m->nCurrow = m->nMaxrow &&Put cursor on last displayed row
- endif
-
- * Display cursor
- if m->nSeekCur>0
- @ m->nCurrow,00;
- fill to m->nCurrow,min(m->nWindcol,m->nSeekCur-1);
- color &x_Clrpslct.
- endif
- if m->nSeekCur<=m->nWindcol
- @ m->nCurrow,max(0,m->nSeekCur);
- fill to m->nCurrow,m->nWindcol;
- color &x_Clrphigh.
- endif
- endif
-
- m->lRepaint = .F. && Reset redisplay flag
- m->nInkey = inkey(0) && Get a key-stroke
- do case
- case m->nInkey=-400 && Shift-Tab
- if isblank(m->cSeek)
- if m->lBell
- @ 00,00 say chr(7)
- endif
- else
- if len(m->cSeek)=m->nSeekCur
- m->cSeek = ""
- m->lSeek = .T.
- else
- goto m->nRecno && Record at top of window
- skip m->nCurrow && Cursor row
- * Currently seeked string
- m->cStr = substr(&cDisplay.,1,m->nSeekCur)
- * if the last character is a chr(29)
- if substr(m->cStr,len(m->cStr),1)=chr(29)
- * Remove the chr(29)
- m->cStr = substr(m->cStr,1,len(m->cStr)-1)
- endif
- * if there is a chr(29)
- if chr(29)$m->cStr
- * Remove everything after the last chr(29)
- m->cSeek = substr(m->cSeek, 1, ;
- len(m->cSeek)-len(m->cStr) + ;
- Rat(chr(29), m->cStr))
- else
- * Remove everything
- m->cSeek = ""
- endif
- m->lSeek = .T.
- endif
- endif
-
- case m->nInkey=3 && PageDown
- m->cSeek = "" && clear seek string
- m->nNewscur = 0 && clear seek cursor
- if m->nCurrow=m->nMaxrow
- && Is cursor on last line in window?
- goto m->nRecno && Record at top of window
- skip m->nWindrow+1 && Number of records in window
- if eof()
- if m->lBell
- @ 00,00 say chr(7)
- && No more records past bottom of
- endif && window
- else
- skip -1 && Put bottom record at top of
- && window
- m->nRecno = recno()
- && New record for top of window
- m->lRepaint = .T. && Redisplay window
- endif
- else && Cursor is not on last line in
- && window
- m->nNewrow = m->nMaxrow && Put cursor on last line in
- endif && window
-
- case m->nInkey=5 && Up Arrow
- m->cSeek = "" && clear seek string
- m->nNewscur = 0 && clear seek cursor
- if m->nCurrow>0 && Is cursor below top of
- && window?
- m->nNewrow = m->nCurrow - 1 && Move cursor up
- else && Cursor is at top of window
- goto m->nRecno && Record at top of window
- skip -1
- if bof()
- if m->lBell
- @ 00,00 say chr(7) && No previous record
- endif
- else
- m->nRecno = recno() && New record for top of window
- m->lRepaint = .T. && Redisplay window
- endif
- endif
-
- case m->nInkey=9 && Tab
- goto m->nRecno && Record at top of window
- skip m->nCurrow && Cursor row
- * Characters after currently seeked string
- m->cStr = substr(&cDisplay.,m->nSeekCur+1)
- if (chr(29)$m->cStr) && Tab marker included?
- * Seek everything up to the tab marker
- m->cStr = substr(m->cStr,1,at(chr(29),m->cStr)-1)
- if .not. seek(m->cKey+m->cSeek+m->cStr)
- m->cStr = upper(m->cStr)
- endif
- if seek(m->cKey+m->cSeek+m->cStr)
- m->cSeek = m->cSeek + m->cStr
- m->lSeek = .T.
- else
- if m->lBell
- @ 00,00 say chr(7)
- endif
- endif
- else
- if m->lBell
- @ 00,00 say chr(7)
- endif
- endif
-
- case m->nInkey=13 .or. m->nInkey=23
- && Enter, Ctrl-W, or Ctrl-End
- goto m->nRecno && Record at top of window
- skip m->nCurrow && Cursor row
- m->cReturn = &cReturn. && Return value
- m->lMore = .F. && Exit main loop
-
- case m->nInkey=17 .or. m->nInkey=27 && Ctrl-Q .or. Escape
- m->cReturn = "" && Return value
- m->lMore = .F. && Exit main loop
-
- case m->nInkey=18 && Page Up
- m->cSeek = "" && clear seek string
- m->nNewscur = 0 && clear seek cursor
- if m->nCurrow=0 && Is cursor on top line of
- && window?
- goto m->nRecno && Record at top of window
- skip -m->nWindrow && Number of records in window
- if bof()
- if m->lBell
- @ 00,00 say chr(7) && No more records above top of
- endif && window
- else
- m->nRecno = recno() && New record for top of window
- m->lRepaint = .T. && Redisplay window
- endif
- else && Cursor is not on top line of
- && window
- m->nNewrow = 0 && Put cursor on top line of
- endif && window
-
- case m->nInkey=24 && Down Arrow
- m->cSeek = "" && clear seek string
- m->nNewscur = 0 && clear seek cursor
- if m->nCurrow<m->nMaxrow && Is cursor above bottom of
- && window?
- m->nNewrow = m->nCurrow + 1 && Move cursor down
- else && Cursor is at bottom of window
- goto m->nRecno && Record at top of window
- skip m->nWindrow+1 && skip to first record below
- if eof() && window
- if m->lBell
- @ 00,00 say chr(7) && No records below window
- endif
- else
- goto m->nRecno && Record at top of window
- skip +1
- m->nRecno = recno() && New record for top of window
- m->lRepaint = .T. && Redisplay window
- endif
- endif
-
- case m->nInkey=2 .or. m->nInkey=30 && End .or. Ctrl-Page Down
- m->cSeek = "" && clear seek string
- m->nNewscur = 0 && clear seek cursor
- goto bottom && Last record in database
- skip -m->nWindrow && Number of records in
- && window
- m->nNewrow = m->nWindrow && Put cursor on bottom line
- && of window
- m->nRecno = recno() && New record for top of window
- m->lRepaint = .T. && Redisplay window
-
- case m->nInkey=26 .or. m->nInkey=31 && Home .or. Ctrl-Page Up
- m->cSeek = "" && clear seek string
- m->nNewscur = 0 && clear seek cursor
- goto top && First record in database
- m->nNewrow = 0 &&Put cursor on top line of
- && window
- m->nRecno = recno() && New record for top of
- && window
- m->lRepaint = .T. && Redisplay window
-
- case m->nInkey>31 .and. m->nInkey<127
- && Displayable character -
- && Seek it
- m->cInkey = chr(m->nInkey)
- if .not. seek(m->cKey+m->cSeek+m->cInkey)
- m->cInkey = upper(m->cInkey)
- endif
- if seek(m->cKey+m->cSeek+m->cInkey) && Seek with new
- && character
- m->cSeek = m->cSeek + m->cInkey && Add new character
- m->lSeek = .T. && to seek string
- else
- if m->lBell
- @ 00,00 say chr(7) && Seek with new character
- endif && failed
- endif
-
- case m->nInkey=127 && Back Space
- if len(m->cSeek)>0 && Seek string is non-blank
- * Remove last character from seek string
- m->cSeek = left(m->cSeek,len(m->cSeek)-1)
- m->lSeek = .T.
- else
- if m->lBell
- @ 00,00 say chr(7) && Seek string is blank
- endif
- endif
-
- otherwise && Unknown key
- B=.T. && Breakpoint - used for debugging
- release B
- endcase
- enddo
-
- * Deactivate and release windows
- deactivate window wPickList2
- deactivate window wPickList1
- release windows wPickList1,wPickList2
-
- * Restore database environment
- if .not.isblank(m->cKey)
- set key to
- endif
-
- *-- Cleanup
- set console &cConsole.
- set cursor &cCursor.
- set escape &cEscape.
- set talk &cTalk.
-
- RETURN m->cReturn
- *-- EoF: Pick1()
-
- FUNCTION Pick2
- *-----------------------------------------------------------------------
- *-- Programmer..: Malcolm C. Rubel
- *-- Date........: 05/18/1992
- *-- Notes.......: I stole ... er ... lifted ... this from Data Based
- *-- Advisor (Nov. 1991), and dUFLPed it, as well as
- *-- removing the FoxPro code ... It's purpose is to
- *-- create a popup/picklist that will find the proper
- *-- location (used with a GET) on the screen for itself,
- *-- display the popup and return the appropriate value
- *-- ...
- *-- Written for.: dBASE IV, 1.1
- *-- Rev. History: 11/01/1991 -- Malcom C. Rubel -- Original Code
- *-- 05/15/1992 -- Ken Mayer -- several things. First, I
- *-- dUFLPed the code, and documented it heavier than the
- *-- original. next, I had to write a function (USED()),
- *-- as there wasn't one sitting around that I could see.
- *-- I added the 'cTag' parameter, as well as a few minor
- *-- changes to the other functions that come with this
- *-- routine ...
- *-- 05/19/1992 -- Resolved a few minor problems, removed
- *-- routine PK_SHOW as being unnecessary (used @Getrow...
- *-- GET to redisplay field/memvar). Added IsBlank() (copy
- *-- of EMPTY()) to handle different field types (original
- *-- only wanted characters).
- *-- Calls.......: ScrRow() Function in SCREEN.PRG (and here)
- *-- ScrCol() Function in SCREEN.PRG (and here)
- *-- Used() Function in FILES.PRG (and here)
- *-- Called by...: Any
- *-- Usage.......: Pick2("<cLookfile>","<cTag>","<cSrchfld>", ;
- *-- "<cRetfld>",<nScrrow>,<nScrcol>)
- *-- Example.....: @10,20 get author ;
- *-- valid required pick2("Library","Author",;
- *-- "Last","Last",10,20)
- *-- Returns.....: lReturn (found/replaced a value or not ...)
- *-- Parameters..: cLookfile = file to lookup in
- *-- cTag = MDX Tag to use (if blank, will use the
- *-- first tag in the MDX file, via the TAG(1)
- *-- option ...)
- *-- cSrchfld = field(s) to browse -- if blank, function
- *-- will try to use a field of same name as
- *-- what cursor is on.
- *-- cRetfld = name of field value is to be returned
- *-- from.
- *-- nScrrow = screen-row (of GET) -- if blank, function
- *-- will determine (use ,, to blank it ... or
- *-- 0)
- *-- nScrcol = screen-col (of GET) -- if blank, function
- *-- will determine
- *-----------------------------------------------------------------------
-
- parameters cLookfile, cTag, cSrchfld, cRetfld, nScrrow, nScrcol
-
- private cLookfile, cSrchfld, cRetfld, nScrrow, nScrcol, cVarName,;
- xValReturn, lWasopen, cCurrbuff, lExact, lReturn, lIsfound,;
- cBarfields, nWinWidth, nGetrow, nGetcol
-
- m->lReturn = .T. && return value must be a logical
- && assume the best ...
- m->cVarName = varread() && name of the variable at GET
- m->xVarvalue = &cVarName. && value of the variable at GET
-
- *-- was a 'fieldname' to get value from passed to function?
- if isblank(m->cRetfld) && passed as a null
- m->cRetfld = m->cSrchfld && we'll return contents of same
- && name as the search field
- endif
-
- m->nScrrow = ScrRow() && get row for picklist
- m->nScrcol = ScrCol() && get column for picklist
- m->cCurrbuff = alias() && current buffer (work area)
- m->lExact = set("EXACT") = "ON" && store status of 'EXACT'
- set exact on && we want 'exact' matches ...
-
- *-- deal with the 'lookup' file -- if not open, open it, if open,
- *-- select it ...
- if .not. used(m->cLookfile) && file not open
- select select() && find next open area
- use &cLookfile. && open file
- m->lWasopen = .F.
- else
- select (m->cLookfile) && file IS open, move to it ...
- m->lWasopen = .T.
- endif
-
- *-- deal with MDX tag for 'lookup' file ...
- if len(trim(m->cTag)) = 0 && if a null tag was sent,
- set order to tag(1) && set the order to first tag
- else
- set order to &cTag. && set it to what user passed.
- endif
-
- *-- screen positions ...
- m->nGetrow = row() && position of 'get' on screen
- m->nGetcol = Iif(isblank(m->xVarvalue),col(),col()-len(&cRetfld.))
- && get column of 'get' ...
-
- *-- if field is empty, do a lookup, otherwise, look for it in table
- if isblank(m->xVarvalue) && no data in field
- m->lIsfound = .F. && automatic lookup
- else
- m->lIsfound = seek(m->xVarvalue) && look for it in table
- endif
-
- *-- if not found, or field was empty, bring up the lookup ...
- if .not. m->lIsfound && not in table
- go top && move pointer to top of 'table'
- *-- make sure it fits on screen
- if m->cRetfld = m->cSrchfld && one browse field
- nWim->nWidth = len(&cSrchfld.) + 3 && width
- m->cBarfields = m->cSrchfld && set the 'browse fields'
- else && else multiple ....
- nWim->nWidth = len(&cSrchfld.)+len(&cRetfld.)+5
- m->cBarfields = m->cSrchfld+", "+m->cRetfld
- endif
-
- *-- this is how we determine where to start the browse table ...
- m->nScrcol = iif(m->nScrcol + nWim->nWidth>77, 77-nWim->nWidth, ;
- m->nScrcol)
- m->nScrrow = iif(m->nScrrow>14,14,m->nScrrow)
-
- *-- set it up ...
- define window wPick from m->nScrrow,m->nScrcol+2 to ;
- m->nScrrow+10,m->nScrcol+nWim->nWidth+2 panel
- activate window wPick
- *on key label ctrl-m keyboard chr(23)
- && when user presses <enter> force an <enter> ... weird.
-
- *-- activate
- browse fields &cBarfields. freeze &cSrchfld. noedit ;
- noappend nodelete nomenu window wPick
- clear typeahead && in case they pressed the <Enter> key
- on key label ctrl-m && reset
- release window wPick
- if lastkey() # 27 && not the <Esc> key
- store &cRetfld. to &cVarName. && put return value into
- else && var ...
- m->lReturn = .F.
- endif
- else
- store &cRetfld. to &cVarName.
- endif
-
- @m->ngetrow, m->ngetcol get &cVarName. && display new value in
- && field/memvar on screen
- clear gets && clear gets from this
- && function
- *-- reset work areas, and so on ...
- if .not. m->lExact
- set exact off
- endif
- if .not. m->lWasopen
- use
- endif
- if len(m->cCurrbuff) # 0
- select (m->cCurrbuff)
- else
- select select()
- endif
-
- RETURN (m->lReturn)
- *-- EoF: Pick2()
-
- FUNCTION ScrRow
- *-----------------------------------------------------------------------
- *-- Programmer..: Malcolm C. Rubel
- *-- Date........: 05/15/1992
- *-- Notes.......: Returns the postion of the current 'get'. if memvar
- *-- Scrrow already exists, returns the value of that,
- *-- unless it's zero, in which case we return the current
- *-- position. This is part of PICK2.
- *-- Written for.: dBASE IV, 1.1
- *-- Rev. History: 11/01/1991 -- Original release
- *-- 05/15/1992 -- Ken Mayer (KENMAYER) to deal with a
- *-- value of 0 for the nScrrow memvar.
- *-- Calls.......: none
- *-- Called by...: Pick2() Function in PICKLIST.PRG
- *-- Usage.......: Scrrow()
- *-- Example.....: nScrrow = Scrrow()
- *-- Returns.....: Numeric -- position of cursor on screen
- *-- Parameters..: none
- *-----------------------------------------------------------------------
-
- if type('m->nScrrow') # 'N' .or. m->nScrrow = 0
- RETURN (row())
- else
- RETURN (m->nScrrow)
- endif
- *-- EoF: Scrrow()
-
- FUNCTION ScrCol
- *-----------------------------------------------------------------------
- *-- Programmer..: Malcolm C. Rubel
- *-- Date........: 05/15/1992
- *-- Notes.......: Returns the postion of the current 'get'. if memvar
- *-- nScrcol already exists, returns the value of that,
- *-- unless it's zero, in which case we return the current
- *-- position. This will also return a different value
- *-- based on whether or not the field has something in it
- *-- or not ... This is part of PICK2.
- *-- Written for.: dBASE IV, 1.1
- *-- Rev. History: 11/01/1991 -- Original release
- *-- 05/15/1992 -- Ken Mayer (71333,1030) to deal with a
- *-- value of 0 for the nScrcol memvar.
- *-- Calls.......: none
- *-- Called By...: Pick2()
- *-- Usage.......: Scrcol()
- *-- Example.....: nScrcol = Scrcol()
- *-- Returns.....: Numeric -- position of cursor on screen
- *-- Parameters..: none
- *-----------------------------------------------------------------------
-
- if type('m->nScrcol') # 'N' .or. m->nScrcol = 0
- if isblank(m->cRetfld)
- RETURN col() + len(m->cRetfld)
- else
- RETURN col()
- endif
- else
- RETURN (m->nScrcol)
- endif
-
- *-- EoF: Scrcol()
-
- PROCEDURE Pick3
- *-----------------------------------------------------------------------
- *-- Programmer..: Martin Leon (HMAN) (A-T)
- *-- Date........: 07/12/1991
- *-- Notes.......: A "generic" PickList routine ...
- *-- Written for.: dBASE IV, 1.1
- *-- Rev. History: 11/01/1990 -- Original release
- *-- Published in TechNotes, November, 1990 (DIYPOPUP)
- *-- 07/12/1991 -- Modified for dHUNG/dUFLP standards, Ken
- *-- Mayer
- *-- Calls.......: none
- *-- Called by...: Any
- *-- Usage.......: do Pick3 with "<cFields>", <nUlrow>, <nUlcol>, ;
- *-- <nBrrow>,<nBrcol>, "<cNormcolor>", "<cFieldColor>",;
- *-- "<cBorder>"
- *-- Example.....: Do Pick3 with "First_name+' '+Last_name",5,10,15,60,;
- *-- "rg+/gb","gb/r","DOUBLE"
- *-- Returns.....: indirectly returns the record pointer of record that
- *-- was highlighted when <Enter> was pressed.
- *-- Parameters..: cFields = fields to be displayed in picklist
- *-- nUlrow = Row coordinate of upper left corner
- *-- nUlcol = Column coordinate of upper left corner
- *-- nBrrow = Row coordinate of lower right corner
- *-- nBrcol = Column coordinate of lower right corner
- *-- cNormcolor = Foreground/Background of normal text
- *-- cFieldColor = Foreground/Background of highlighted
- *-- fields
- *-- cBorder = none, SINGLE, DOUBLE (defaults to
- *-- Single if sent as a nul string ("") )
- *-----------------------------------------------------------------------
- parameters cFields, nUlrow, nUlcol, nBrrow, nBrcol, cNormcolor, ;
- cFieldColor, cBorder
-
- m->cCursor = set("CURSOR")
- m->cEscape = set("ESCAPE")
- m->cTalk = set("TALK")
- set cursor off
- set escape off
- set talk off
- m->cTypecheck = type("cFields") + type("nUlrow") + type("nUlcol") + ;
- type("nBrrow") + type("nBrcol") + ;
- type("cNormcolor") + type("cFieldColor") + ;
- type("cBorder")
- m->lError = .F.
- do case
- && Check data types
- case m->cTypecheck # "CNNNNCCC"
- clear
- @ 7,17 say "Data type mismatch -- check all parameters"
- m->lError = .T.
-
- && Check for bottom limit with STatUS on
- case ((m->nBrrow >21 .and. set("DISPLAY") # "EGA43") ;
- .or. (m->nBrrow >39 .and. set("DISPLAY") = "EGA43")) ;
- .and. set("STatUS") = "ON"
- clear
- @ 7,15 say "Cannot use this popup on or below Status line"
- m->lError = .T.
-
- && Check for bottom limit with STatUS off
- case ((m->nBrrow >24 .and. set("DISPLAY") # "EGA43") ;
- .or. (m->nBrrow >42 .and. set("DISPLAY") = "EGA43")) ;
- .and. set("STatUS") = "off"
- clear
- @ 7,16 say "bottom coordinate beyond bottom of screen"
- m->lError = .T.
-
- && Check left & right coordinates
- case m->nUlcol < 0 .or. m->nBrcol > 79
- clear
- @ 7,24 say "Invalid Column coordinate"
- m->lError = .T.
-
- && Check to make sure popup can display at least one record
- case m->nBrrow - m->nUlrow < 2
- clear
- @ 7,19 say "Popup must be at least 3 lines high"
- m->lError = .T.
-
- endcase
-
- if m->lError
- @ 5,5 to 9,70 DOUBLE
- @ 11, 32 say "Press Any Key"
- m->nX = 0
- do while m->nX = 0
- m->nX = inkey()
- enddo
- set cursor &cCursor.
- set escape &cEscape.
- set talk &cTalk.
- RETURN
- endif
-
- && Save colors of normal and fields to restor when done
- m->cFieldset = set("ATTRIBUTES")
- m->cNormset = left(m->cFieldset, at(",",m->cFieldset)-1)
- do while "," $ m->cFieldset
- m->cFieldset = substr(m->cFieldset, at(",",m->cFieldset)+1)
- enddo
-
- && if they were provided, set to colors passed on from calling program
- if len(m->cNormcolor) # 0
- set color of normal to &cNormcolor.
- endif
- if len(m->cFieldColor) # 0
- set color of fields to &cFieldColor.
- endif
-
- m->nPromptW = m->nBrcol - m->nUlcol - 1
- @ m->nUlrow, m->nUlcol clear to m->nBrrow, m->nBrcol
- @ m->nUlrow, m->nUlcol to m->nBrrow, m->nBrcol &cBorder.
-
- if eof()
- skip -1
- endif
-
- && Save current record pointer and determine record number of top
- && record
- m->nTmprec = recno()
- go top
- m->nToprec = recno()
- go m->nTmprec
- m->nMaxrecs = m->nBrrow - m->nUlrow - 1
- m->nKey = 0
- m->lGoBack = .F.
- declare aPrompt[m->nMaxrecs], aRec[m->nMaxrecs]
-
- do while .NOT. m->lGoBack
- m->nChcnum = 1
- m->nToprow = m->nUlrow + 1
- m->nLeftcol = m->nUlcol + 1
- m->nRowoffset = 0
- m->nLastcurs = 0
-
- && This loop puts text into prompts
- do while m->nRowoffset + 1 <= m->nMaxrecs
- if .not. eof()
- m->cTemp = &cFields. && Expands m->cFields into string
- && expression
- aPrompt[m->nChcnum] = substr(m->cTemp, 1, m->nPromptW)
-
- && if prompt doesn't fill entire box, add spaces
- if len(aPrompt[m->nChcnum]) < m->nPromptW
- aPrompt[m->nChcnum] = aPrompt[m->nChcnum] + ;
- space(m->nPromptW - len(aPrompt[m->nChcnum]))
- endif
-
- aRec[m->nChcnum] = recno()
- @ m->nToprow+m->nRowoffset , m->nLeftcol ;
- say aPrompt[m->nChcnum]
- endif
- m->nRowoffset = m->nRowoffset + 1
- m->nChcnum = m->nChcnum + 1
- skip
-
- && if last record reached, clear rest of box
- if eof()
- do while m->nRowoffset + 1 <= m->nMaxrecs
- @ m->nToprow+m->nRowoffset, m->nLeftcol ;
- say space(m->nPromptW)
- m->nRowoffset = m->nRowoffset +1
- enddo
- exit
- endif
- enddo
-
- m->nHighchc = m->nChcnum - 1
- if m->nKey # 2 .and. m->nKey # 3 && if the last key pressed wasn't
- && <end> or <PgDn>
- m->nChcnum = 1
- m->nRowoffset = 0
- else
- m->nChcnum = m->nHighchc
- m->nRowoffset = m->nHighchc - 1
- endif
-
- @ m->nToprow+m->nRowoffset , m->nLeftcol ;
- get aPrompt[m->nChcnum]
- clear gets
-
- && This loops traps the keys
- do while .T.
- m->nKey = inkey()
- do case
-
- case m->nKey = 5 && Up arrow
-
- && if first record displayed is first record in database
- && and it is already highlighted
- if aRec[1] = m->nToprec .and. m->nChcnum = 1
- loop
- endif
-
- && if first record is highlighted but is not top record,
- && shift prompt contents down
- if aRec[1] # m->nToprec .and. m->nChcnum = 1
- go aRec[1]
- m->nX = m->nHighchc
- do while m->nX > 1
- aRec[m->nX] = aRec[m->nX - 1]
- aPrompt[m->nX] = aPrompt[m->nX - 1]
- m->nX = m->nX - 1
- enddo
-
- && get prompt for additional record to be displayed
- skip -1
- aRec[1] = recno()
- m->cTemp = &cFields.
- aPrompt[1] = substr(m->cTemp, 1, m->nPromptW)
- if len(aPrompt[1]) < m->nPromptW
- aPrompt[1] = aPrompt[1] + ;
- space(m->nPromptW - len(aPrompt[1]))
- endif
- skip + m->nMaxrecs
-
- && if maximum possible records aren't displayed
- if m->nHighchc < m->nMaxrecs
- m->nHighchc = m->nHighchc + 1
- skip -1
- aRec[m->nHighchc] = recno()
- m->cTemp = &cFields.
- aPrompt[m->nHighchc] = ;
- substr(m->cTemp,1,m->nPromptW)
- if len(aPrompt[m->nHighchc]) < m->nPromptW
- aPrompt[m->nHighchc] = ;
- aPrompt[m->nHighchc] + ;
- space(m->nPromptW - ;
- len(aPrompt[m->nHighchc]))
- endif
- skip
- endif
-
- && Redisplay prompts with new contents
- m->nX = 1
- do while m->nX < m->nHighchc + 1
- @ m->nToprow + m->nX - 1, m->nLeftcol ;
- say aPrompt[m->nX]
- m->nX = m->nX + 1
- enddo
- m->nChcnum = 2
- endif
-
- m->nChcnum = iif(m->nChcnum = 1, m->nHighchc, ;
- m->nChcnum - 1)
- m->nRowoffset = iif(m->nChcnum = 1, 0,;
- m->nChcnum - 1)
- m->nLastone = iif(m->nChcnum = m->nHighchc, 1,;
- m->nChcnum+1)
- m->nThisone = m->nChcnum
-
- @ m->nToprow + ;
- iif(m->nChcnum = m->nHighchc, 0, m->nRowoffset+1) , ;
- m->nLeftcol say aPrompt[m->nLastone]
- @ m->nToprow+m->nRowoffset , m->nLeftcol ;
- get aPrompt[m->nThisone]
- clear gets
-
- case m->nKey = 24 && Dn arrow
-
- && if last prompt is highlighted and it is last record
- if eof() .and. m->nChcnum = m->nHighchc
- loop
- endif
-
- &&if not at last record and bottom prompt is highlighted,
- && shift prompt contents up
- if .not. eof() .and. m->nChcnum = m->nHighchc
- m->nX = 1
- do while m->nX < m->nMaxrecs
- aRec[m->nX] = aRec[m->nX + 1]
- aPrompt[m->nX] = aPrompt[m->nX + 1]
- m->nX = m->nX + 1
- enddo
-
- && get prompt for additional record to be displayed
- aRec[m->nMaxrecs] = RECNO()
- m->cTemp = &cFields
- aPrompt[m->nMaxrecs] = substr(m->cTemp, 1, ;
- m->nPromptW)
- if len(aPrompt[m->nMaxrecs]) < m->nPromptW
- aPrompt[m->nMaxrecs] = aPrompt[m->nMaxrecs]+;
- space(m->nPromptW - len(aPrompt[m->nMaxrecs]))
- endif
- skip
-
- && Redisplay prompts with new contents
- m->nX = m->nMaxrecs
- do while m->nX > 0
- @ m->nToprow + m->nX - 1, m->nLeftcol ;
- say aPrompt[m->nX]
- m->nX = m->nX - 1
- enddo
- m->nChcnum = m->nMaxrecs - 1
- endif
-
- m->nChcnum = iif(m->nChcnum < m->nHighchc, ;
- m->nChcnum + 1, 1)
- m->nRowoffset = iif(m->nChcnum = 1, 0, m->nChcnum - 1)
- m->nLastone = iif(m->nChcnum = 1, m->nHighchc, ;
- m->nChcnum-1)
- m->nThisone = m->nChcnum
-
- @ m->nToprow + ;
- iif(m->nChcnum = 1, m->nHighchc-1, m->nRowoffset-1) ,;
- m->nLeftcol say aPrompt[m->nLastone]
- @ m->nToprow+m->nRowoffset , m->nLeftcol ;
- get aPrompt[m->nThisone]
- clear gets
-
- case m->nKey = 13 && Enter key
- && Move record pointer and go back to calling program
- go aRec[m->nChcnum]
- m->lGoBack = .T.
- exit
-
- case m->nKey = 3 && PgDn key
-
- &&if last record in .DBF is displayed but not highlighted,
- && move highlight to bottom and wait for next key
- if eof() .and. m->nChcnum # m->nHighchc
- @ m->nToprow + m->nRowoffset, m->nLeftcol ;
- say aPrompt[m->nChcnum]
- @ m->nToprow + m->nHighchc - 1, m->nLeftcol ;
- get aPrompt[m->nHighchc]
- clear gets
- m->nChcnum = m->nHighchc
- m->nRowoffset = m->nChcnum - 1
- loop
- endif
-
- && if highlight is not on last record that is displayed,
- && move highlight to it and wait for next key
- if m->nChcnum # m->nHighchc
- @ m->nToprow + m->nRowoffset, m->nLeftcol ;
- say aPrompt[m->nChcnum]
- @ m->nToprow + m->nHighchc - 1, m->nLeftcol ;
- get aPrompt[m->nHighchc]
- clear gets
- m->nChcnum = m->nHighchc
- m->nRowoffset = m->nChcnum - 1
- loop
- endif
-
- && Highlight is at bottom record displayed but not at eof
- && Move record pointer down to next "page" of records and
- && return to main loop
- if .not. eof()
- go aRec[1]
- skip + m->nMaxrecs
- m->lGoBack = .F.
- exit
- endif
-
- && if none of the above is true, wait for another key
- loop
-
- case m->nKey = 18 && PgUp key
-
- && if top record displayed is top of .DBF but it is
- && not highlighted, move highlight to it and wait for
- && next key
- if aRec[1] = m->nToprec .and. m->nChcnum # 1
- @ m->nToprow + m->nRowoffset, m->nLeftcol ;
- say aPrompt[m->nChcnum]
- @ m->nToprow, m->nLeftcol get aPrompt[1]
- clear gets
- m->nChcnum = 1
- m->nRowoffset = 0
- loop
- endif
-
- && if highlight is not on top record displayed, move
- && highlight to it and wait for next key
- if m->nChcnum # 1
- @ m->nToprow + m->nRowoffset, m->nLeftcol ;
- say aPrompt[m->nChcnum]
- @ m->nToprow, m->nLeftcol get aPrompt[1]
- clear gets
- m->nChcnum = 1
- m->nRowoffset = 0
- loop
- endif
-
- && Highlight is at top record displayed but not at top of
- && DBF. Move record pointer up one "page" worth of
- && records and return to main loop to display new prompts
- if aRec[1] # m->nToprec
- go aRec[1]
- skip - m->nMaxrecs
- m->lGoBack = .F.
- exit
- endif
-
- && if none of the above is true, wait for next key
- loop
-
- case m->nKey = 27 && Esc key
- && Move record pointer to where it was before starting
- && this routine and return to calling program
- m->lAbandon = .T.
- m->lGoBack = .T.
- go m->nTmprec
- exit
-
- case m->nKey = 26 && Home key
-
- && if already at top of DBF, wait for next key
- if aRec[1] = m->nToprec
- loop
- else && go top and return to main loop to display new
- && prompts
- go top
- m->lGoBack = .F.
- exit
- endif
-
- case m->nKey = 2 && End key
-
- &&if last record in DBF is displayed but not highlighted,
- && move highlight to it and wait for next key
- if eof() .and. m->nChcnum # m->nHighchc
- @ m->nToprow + m->nRowoffset, m->nLeftcol ;
- say aPrompt[m->nChcnum]
- @ m->nToprow + m->nHighchc - 1, m->nLeftcol ;
- get aPrompt[m->nHighchc]
- clear gets
- m->nChcnum = m->nHighchc
- m->nRowoffset = m->nChcnum - 1
- loop
- endif
-
- && if last record is not displayed, go to it and
- && return to main loop
- if .not. eof()
- go bottom
- skip - (m->nMaxrecs - 1)
- m->lGoBack = .F.
- exit
- endif
-
- && if none of the above is true, go back and wait for
- && next key
- loop
-
- case m->nKey = 28 && F1 key
- && This is just sample code for the F1 key
- define window TempWin from 5,4 TO 14,75
- activate window TempWin
- @ 1,3 say "Use cursor keys to choose. " + ;
- "Press <Enter> to move record pointer"
- @ 2,5 say "Use <PgUp>, <PgDn>, <Home>, and <End> " + ;
- "to see other records"
- @ 3,26 say "Use <Esc> to abandon"
- @ 5,23 say "Press Any key to Continue"
- m->nX = 0
- do while m->nX = 0
- m->nX = inkey()
- enddo
- deactivate window TempWin
-
- case m->nKey = -1 && F2 key
- && This is just sample code for the F2 key
- SAVE SCREEN TO sScreen
- m->nX = recno()
- go aRec[m->nChcnum]
- set cursor on
- EDIT NOMENU NOAPPEND NODELETE next 1
- * READ is better if you already have a FORMat set.
- set cursor off
- go aRec[m->nChcnum]
- m->cTemp = &cFields. && Expands m->cFields into string
- && expression
- aPrompt[m->nChcnum] = substr(m->cTemp, 1, m->nPromptW)
- if len(aPrompt[m->nChcnum]) < m->nPromptW
- aPrompt[m->nChcnum] = aPrompt[m->nChcnum] + ;
- space(m->nPromptW - len(aPrompt[m->nChcnum]))
- endif
- restore screen from sScreen
- @ m->nToprow+m->nRowoffset, m->nLeftcol ;
- get aPrompt[m->nChcnum]
- clear gets
- if m->nX <= reccount()
- go m->nX
- else
- go bottom
- skip
- endif
- endcase
- enddo
- enddo
-
- && Put colors back to what they were and set CURSOR, escape, and TALK
- && back
- set color of normal to &cNormset.
- set color of fields to &cFieldset.
- set cursor &cCursor.
- set escape &cEscape.
- set talk &cTalk.
-
- RETURN
- *-- EOP: Pick3
-
- FUNCTION Pick4
- *---------------------------------------------------------------------
- *-- Programmer..: Keith G. Chuvala (CIS: 71600,2033)
- *-- Date........: 11/03/1993
- *-- Notes.......: This is a generic picklist routine.
- *-- Written for.: dBASE IV, 1.1
- *-- Rev. History: 10/01/1992 -- Original version
- *-- 11/03/1992 -- Modified to dUFLP it (and use RECOLOR
- *-- to ensure that colors are returned properly) -- Ken
- *-- Mayer
- *-- 02/16/1993 -- Minor changes to deal with small data
- *-- files by Keith.
- *-- 11/03/1993 -- Changes to fix various stuff.
- *-- 11/09/1993 -- Added: Select PICKER command.
- *-- Calls.......: ReColor PROCEDURE in PROC.PRG
- *-- Called by...: Any
- *-- Usage.......: Pick4(nRow, nCol, cTitle, cFileSpecs, cListwhat, ;
- *-- nRetchar, nRetType, cColors
- *-- Example.....: ?Pick4(10,10,"Order Stock","Stock,InvNum",;
- *-- "left(invno,10)+' '+desc",4,1,"r/w,b/w,w/b")
- *-- Returns.....: number of characters from prompt() or
- *-- if user presses <Esc>, returns .F.
- *-- Parameters..: nRow = Upper Left Corner Row
- *-- nCol = Upper Left Corner Column
- *-- cTitle = Title to display at top of list
- *-- cFileSpecs = "FILENAME,ORDER,SET_KEY_TO"
- *-- cListwhat = What should display as prompt
- *-- nRetchar = Number of characters of prompt to
- *-- return
- *-- nReturntype = 0 = KEYB(), 1 = Normal Return
- *-- cColors = Background/Unselected Items,;
- *-- Selected letters/border, selected bar
- *-- example: rg+/gb,w+/b,w+/n
- *-- rg+/gb = unselected items (and
- *-- background)
- *-- w+/b = selected letter(s)
- *-- w+/n = currently highlighted bar
- *---------------------------------------------------------------------
-
- parameters nRow, nCol, cTitle, cFileSpecs, cListwhat, nRetchar, ;
- nReturntype, cColors
-
- private nLastBar, cTalk, cStatus, cNColor, cBColor, cHColor, nPick,;
- cWindow, cCursor, cAlias, sPick, cAttrib, nLastBar, nDone,;
- nX, nP, nO, aBar, lRefresh, nLCol, nRCol, nPKey, cExact, ;
- cSeek, nOldRow, nOldWidth, xRetVal, cSetKey, nMaxBar
-
- m->ctalk = set("talk")
- set talk off
-
- *--------------------------------------------------------------------
- * Default colors selections.
- * m->cBColor - Border of picklist box
- * m->cNColor - Interior of picklist
- * m->cHColor - selection bar
- *--------------------------------------------------------------------
-
- m->cNColor = "w/n"
- m->cBColor = "w+/n"
- m->cHColor = "n/w"
-
- * If the user passed the cColors param, set the colors accordingly
-
- if len(m->cColors) > 0
- m->nX = at(",",m->cColors)
- m->cNColor = left(m->cColors,m->nX-1)
- m->cColors = substr(m->cColors,m->nX+1)
- if len(m->cColors) > 0
- m->nX = at(",",m->cColors)
- m->cBColor = iif(m->nX > 0,left(m->cColors,m->nX-1),m->cColors)
- m->cColors = iif(m->nX > 0,substr(m->cColors,m->nX+1),"")
- if len(m->cColors) > 0
- m->cHColor = m->cColors
- endif
- endif
- endif
-
- *--------------------------------------------------------------------
- * Save the current environment as much as possible, set up our
- * preferences for the picklist.
- *--------------------------------------------------------------------
- m->cAttrib = set("attr")
- set color to &cNColor.,&cNColor.
- save screen to sPick
- m->cStatus = set("status")
- set status off
- restore screen from sPick
- m->cCursor = set("cursor")
- set cursor off
- m->cWindow = window()
- activate screen
- m->cExact = set("exact")
- m->cSeek = ""
- set exact off
- set near off
-
- *--------------------------------------------------------------------
- * Let the user know we're working....
- *--------------------------------------------------------------------
- @ 9,32 clear to 9,47
- @ 9,32 fill to 11,49 color n+/n && shadow!
- @ 8,31 to 10,48 color &cBColor.
- @ 9,32 say " Please wait... " color &cNColor.
-
- *--------------------------------------------------------------------
- * Set up the picklist.
- *--------------------------------------------------------------------
-
- * Handle the file specs first. The cFileSpecs parameter can have up
- * to 3 components, each separated by commas:
- *
- * "filename,index_tag,key_range"
-
- * Results are stored in:
- * m->cFile - the name of the .DBF
- * m->cOrder - the index tag to use (if supplied)
- * m->cSetKey - the key or key range (if supplied)
-
- m->cOrder = ""
- m->cSetKey = ""
- m->cFile = m->cFileSpecs
- m->nX = at(",",m->cFileSpecs)
- if m->nX > 0
- m->cFile= left(m->cFileSpecs,m->nX-1)
- m->cFileSpecs = substr(m->cFileSpecs,m->nX+1)
- if len(m->cFileSpecs) > 0
- m->nX = at(",",m->cFileSpecs)
- m->cOrder = iif(m->nX>0,left(m->cFileSpecs,m->nX-1), ;
- m->cFileSpecs)
- m->cFileSpecs = iif(m->nX>0,substr(m->cFileSpecs,m->nX+1),"")
- if len(m->cFileSpecs) > 0
- m->cSetKey = m->cFileSpecs
- endif
- endif
- endif
-
- * Now save the current alieas in m->cAlias, open the file, and set up
- * the index tag and key range, if provided.
-
- m->cAlias = alias()
- use (cFile) again in select() alias picker
- select picker && 11/9/93 -- added here -- Ken
- if len(trim(m->cOrder)) > 0
- set order to (cOrder)
- else
-
- * This block assumes you want to use a default index tag if none
- * was supplied by the user. Comment these three lines out if
- * you prefer "natural" order to be the default.
-
- if len(tag(1)) > 0
- set order to tag(1)
- endif
- endif
- set deleted on
-
- if len(trim(m->cSetKey)) > 0
- if at(",",m->cSetKey) > 0
- m->cSetKey = "range "+ m->cSetKey
- endif
- set key to &cSetKey.
- endif
- go top
-
- * These variables are current state indicators:
- *
- * m->nP - the current position of the selection bar
- * m->nO - the most recent position of the selection bar
- * m->nDone - set when a terminating key has been pressed
- * m->lRefresh - indicates the need to get a new set of records
- * m->nOldWidth - saves the width of the picklist on-screen
- * m->nWidth - the calculated width of the current picklist
- * m->nOldRow - saves the bottom row of the picklist
- * m->nLastBar - the bottom bar # of the currrent display
- * m->nMaxBar - the maximum number of bars in the list
- * m->nLCol - the leftmost column of the picklist box
- * m->nRCol - the rightmost column of the box
- * m->nPKey - the last key pressed
- *
- * m->nX is used as a loop counter
-
-
- m->nP = 1
- m->nO = 1
- m->lRefresh = .t.
- m->nDone = iif(reccount() < 1,2,0)
- m->nWidth = iif("" <> cTitle,len(cTitle),12)
- m->nOldWidth = -1
- m->nOldRow = -1
- m->nMaxBar = (22 - nRow)
- m->nLastBar = (nMaxBar - 1)
- m->nLCol = nCol
- m->nRCol = 77
- m->nPKey = 0
-
- * Array aBar[] holds the actual contents of the picklist
-
- declare aBar[m->nMaxBar]
-
- *--------------------------------------------------------------------
- * Display and process the picklist.
- *--------------------------------------------------------------------
-
- lFirst = .t.
- do while m->nDone = 0
-
- * Check the need for a redraw
-
- if lFirst .or. (m->lRefresh .and. .not. eof("picker"))
- lFirst = .f.
- m->nWidth = len(cTitle) + 2
-
- * Fill aBar[] one record at a time, keep track of the widest
- * entry (in m->nWidth) for display purposes
-
- m->nX = 0
- do while m->nX < (nMaxBar) .and. .not. eof("picker")
- m->nX = m->nX + 1
- aBar[m->nX] = &clistwhat.
- if len(aBar[m->nX]) > m->nWidth
- m->nWidth = len(aBar[m->nX])
- endif
- skip 1
- enddo
-
- * If there are no entries, we need to fake a blank one
- if m->nX = 0
- aBar[1] = "<No Entries>"
- m->nX = 1
- endif
-
- * Now that we've filled the array or some portion of it, we
- * need to make sure we don't exceed the right edge of the
- * screen. m->nRCol and m->nLCol will end up holding valid
- * coordinates that are the right width to display the current
- * set of records on-screen.
-
- m->nLastBar = m->nX
- m->nLCol = m->nCol
- m->nRCol = m->nLCol + m->nWidth + 4
- do while (m->nRCol > 77) .and. (m->nLCol > 0)
- if m->nLCol > 1
- m->nRCol = m->nRCol - 1
- m->nLCol = m->nLCol - 1
- else
- m->nRCol = 77
- endif
- enddo
-
- * If our width has changed from the last time, this code will
- * redraw the box.
-
- if (m->nWidth <> m->nOldWidth) .or. (m->nLastBar <> m->nOldRow)
- restore screen from sPick
- @ m->nRow+1, m->nLCol+1 fill to ;
- m->nRow+m->nLastBar+2,m->nRCol+2 color w/n
- @ m->nRow , m->nLCol to ;
- m->nRow+m->nLastBar+1,m->nRCol color &cBColor.
- @ m->nRow , m->nLCol+1 say '[' color &cBColor.
- @ m->nRow , m->nLCol+2 say m->cTitle color &cNColor.
- @ m->nRow , m->nLCol+2+len(m->cTitle) say ']' ;
- color &cBColor.
- endif
-
- * Since there might be leftover records on the screen from the
- * last time through the loop, we'll clear the internal area of
- * the picklist box.
-
- @ m->nRow+1, m->nLCol+1 clear to m->nRow+m->nLastBar,m->nRCol-1
-
- * Now we save the width and the bottom row for comparison next
- * time through the ringer....
-
- m->nOldRow = m->nLastBar
- m->nOldWidth = m->nWidth
-
- * Time to display the contents of the array, which is what the
- * user sees as the actual list of choices.
-
- m->nX = 1
- do while m->nX <= m->nLastBar
- @ m->nX+m->nRow,m->nLCol+2 say " "+aBar[m->nX] ;
- color &cNColor.
- m->nX = m->nX + 1
- enddo
- endif
-
- * If PgDn was the last key pressed, we might want to posistion
- * the selection bar at the end of the list
-
- if (m->nPKey = 3) .and. eof("picker")
- m->nP = m->nLastBar
- endif
-
- * If the box dimensions have changed, we might need to readjust
- * the position of the selection bar accordingly.
-
- if m->nP > m->nLastBar
- m->nP = m->nLastBar
- endif
-
- * Display the most recently selected bar in the "normal" color
- * (if necessary), then display the currently selected bar in the
- * "highlight" color.
-
- if m->nO <= m->nLastBar
- @ m->nRow+m->nO, m->nLCol+2 fill to m->nRow+m->nO,m->nRCol-2 ;
- color &cNColor.
- endif
- @ m->nRow+m->nP, m->nLCol+2 fill to m->nRow+m->nP,m->nRCol-2 ;
- color &cHColor.
-
- * cSeek is the character variable that holds any alphanumeric
- * keypresses the user might have made. If not empty, we will
- * display the appropriate keystrokes as highlighted on the
- * screen. This effect is similar to dBASE's own internal pick-
- * lists.
-
- m->nX = at(upper(m->cSeek),upper(aBar[m->nP]))
- if m->nX > 0
- @ m->nRow+m->nP,m->nLCol+2+m->nX fill to ;
- m->nRow+m->nP,m->nLCol+1+m->nX+len(m->cSeek) color &cBColor.
- endif
-
- * We need to save the current bar position for comparison the
- * next time through the loop.
-
- m->nO = m->nP
-
- * Process user keystrokes. Just a big, ugly case construct.
-
- m->nPKey = inkey(0)
- do case
- case m->nPKey = 5 && up
- m->nP = m->nP - 1
- if m->nP < 1
- m->nPKey = 18
- m->nP = m->nLastBar
- endif
- m->cSeek = ""
- case m->nPKey = 24 && down
- m->nP = m->nP + 1
- if m->nP > m->nLastBar
- if .not. eof("picker")
- m->nPKey = 3
- m->nP = 1
- else
- m->nPKey = 0
- m->nP = m->nP - 1
- endif
- endif
- m->cSeek = ""
- endcase
- m->lRefresh = .t.
- do case
- case m->nPKey = 18 && pgup, up
- skip - ((nMaxBar * 2) - 2)
- if bof()
- m->nPKey = 26
- go top
- m->nP = 1
- endif
- m->cSeek = ""
- case m->nPKey = 26 && home
- go top
- m->nP = 1
- m->cSeek = ""
- case m->nPKey = 2 && end
- go bottom
- skip -(nMaxBar-1)
- if bof()
- go top
- m->nP = m->nLastBar
- else
- m->nP = m->nMaxBar
- endif
- m->cSeek = ""
- case m->nPKey = 27 && esc
- m->nDone = 1
- case (m->nPKey = 13) .or. (m->nPKey = 23) && c/r
- m->nPick = aBar[m->nP]
- m->nDone = 1
- case ((m->nPKey >= asc(" ")) .and. (m->nPKey <= asc("z"))) ;
- .or. (m->nPKey = 127)
-
- * Here is where the cSeek variable gets filled with whatever
- * alphanumeric keys the user might press. First we verify
- * that there's an index tag in use. If so, we try SEEKing
- * the data. If not successful, we try its uppercase
- * equivalent just to be sure. NOTE: This works great with
- * character-based data. On any other type of index key,
- * you're on your own!
-
- * Handle the backspace key here
- if m->nPKey = 127
- m->cSeek = left(m->cSeek,len(m->cSeek)-1)
- else
- m->cSeek = m->cSeek + chr(m->nPKey)
- endif
-
- * Try the SEEK
-
- if .not. isblank(cOrder)
- seek(m->cSeek)
- if .not. found()
- seek(upper(m->cSeek))
- endif
- endif
-
- * If unsuccessful, beep at 'em.
-
- if .not. found()
- m->cSeek = left(m->cSeek,len(m->cSeek)-1)
- ?? chr(7)
- endif
-
- * If the user has pressed the backspace key enough times
- * that cSeek is empty, let's rewind to the top of the file.
-
- if len(trim(m->cSeek)) = 0
- go top
- endif
-
- * No matter what, we're gonna want to refresh the data here,
- * since we've been doing SEEKs and so forth....
-
- m->lRefresh = .t.
- m->nPKey = 3
- otherwise
- if (m->nPKey <> 3)
- m->lRefresh = .f.
- endif
- endcase
- enddo
-
- * We'll return either a string of characters or a logical value
- * depending on the value of the nRetType the program passed us.
- * If it's a 0, we use KEYBOARD to stuff data into the keyboard
- * buffer, making a nice hook for READs and so forth. If nRetType
- * is non-zero, we return a string 'nRetChar' characters long.
-
- if m->nPKey <> 27
- if m->nreturntype = 0
- if m->nPick = "<No Entries>" && Don't send this back!
- m->nPick = ""
- endif
- keyboard chr(26)+chr(25)+left(m->nPick,m->nretchar)+chr(13)
- endif
- m->xRetVal = iif(m->nreturntype = 0, .t. , ;
- iif(m->nPKey = 27 .or. (m->nPick = "<No Entries>"),"",;
- left(m->nPick,m->nretchar)))
- else
- m->xRetVal = .f.
- endif
-
- * We've played around a lot here, so we must clean up after our-
- * selves! After closing the picker work area, we try to make
- * everything else look just as it did when we entered the function.
-
- use in picker
-
- if len(trim(m->cAlias)) > 0
- select (m->cAlias)
- endif
-
- if len(trim(m->cWindow)) > 0
- activate window &cWindow.
- endif
-
- do recolor with m->cAttrib
- set status &cStatus.
- set talk &ctalk.
- set cursor &cCursor.
- set exact &cExact.
- restore screen from sPick
- release screen sPick
-
- RETURN m->xRetVal
- *-- EoF: Pick4()
-
- FUNCTION PopList
- *-----------------------------------------------------------------------
- *-- Programmer..: Angus Scott-Fleming (CIS: 75500,3223)
- *-- Date........: 11/30/1992
- *-- Notes.......: Display a popup constructed from up to 9 options. The
- *-- routine then keyboards the first characters of the
- *-- selected option up to the length of the field/memvar)
- *-- directly into field/memvar. used in place of the
- *-- picture function "@M" built-in to dBASE IV. This
- *-- should be used only in a VALID REQUIRED clause, not a
- *-- WHEN clause.
- *-- Written for.: dBASE IV, 1.5
- *-- Rev. History: 11/30/1992 -- Original release
- *-- Calls.......: none
- *-- Called by...: Any
- *-- Usage.......: PopList(<cP1>,<cP2>,<cP3>,<cP4>,<cP5>,...<cP9>)
- *-- Example.....: @6,37 get cHanded picture "!" valid required;
- *-- poplist("Right-handed","Left-handed")
- *-- Returns.....: Logical: .T. when variable being read matches
- *-- options, .F. otherwise
- *-- Parameters..: cP1 = First parameter for list
- *-- ...
- *-- cP9 = Last this is max routine will allow ... number
- *-- varies, should always have at least two,
- *-- otherwise, what's the point?
- *-----------------------------------------------------------------------
-
- parameters cP1, cP2, cP3, cP4, cP5, cP6, cP7, cP8, cP9
- private nPopLen, nPop, nPopRow, nPopCol, nPopECol, nPopBRow, nPop, ;
- cPoppar, cPopread, cPopret, nPopInLen, cPopinput
-
- m->nPopLen = 0
- m->nPop = 0
- m->cPopread = varread() && get memvar/field being read
- m->cPopinput = &cPopread && store again?
- m->nPopInLen = len(m->cPopinput) && get length
- declare aPopBar[pcount()] && define array
- do while m->nPop < pcount()
- m->nPop = m->nPop + 1
- m->cPoppar = "cP"+Ltrim(STR(m->nPop))
- aPopBar[m->nPop] = &cPoppar.
- m->nPopLen = max(m->nPopLen,len(aPopBar[m->nPop]))
- if (m->cPopinput=left(aPopBar[m->nPop],m->nPopInLen)) .and. ;
- (left(aPopBar[m->nPop],m->nPopInLen)=m->cPopinput)
- RETURN .T.
- endif
- enddo
-
- *-- set coordinates of popup (checking for edge of screen ...)
- m->nPopRow = row()
- m->nPopCol = col() + m->nPopInLen
- if m->nPopRow + pcount() + 1 > 24
- m->nPopRow = 23-pcount()
- endif
- m->nPopBRow = m->nPopRow + pcount() + 1
- if m->nPopCol + m->nPopLen > 79
- m->nPopCol = 75-m->nPopLen
- endif
- m->nPopECol = m->nPopCol + m->nPopLen + 1
-
- *-- define popup
- save screen to sPopList
- define popup PopList from m->nPopRow,m->nPopCol ;
- to m->nPopBRow,m->nPopECol
- m->nPop = 0
- do while m->nPop < pcount()
- m->nPop = m->nPop + 1
- define bar m->nPop of PopList prompt aPopBar[m->nPop]
- enddo
- on selection popup PopList deactivate popup
- activate popup PopList
-
- *-- now we have it, let's deal with output
- m->cPopret = left(prompt(),m->nPopInLen)
-
- *-- cleanup screen and memory
- release popup PopList
- restore screen from sPopList
- release screen sPopList
-
- *-- replace data in field for user
- *-- space is necessary for the valid required error about
- *-- "Editing condition not satisified ..."
- *-- chr(26) and chr(25) move cursor to "home" and delete contents
- *-- of field, so new data can be keyboarded in
- keyboard " "+chr(26)+chr(25)+m->cPopret + ;
- iif(set("CONFIRM")="ON",chr(13),"")
-
- RETURN .F.
- *-- EoF: PopList()
-
- PROCEDURE Diacrit
- *-----------------------------------------------------------------------
- *-- Programmer..: Ken Mayer (CIS: 71333,1030)
- *-- Date........: 06/30/1993
- *-- Notes.......: used to insert those letters with diacritical marks
- *-- into your input screens. This routine brings up a
- *-- picklist with all the standard diacrit characters
- *-- built into the ASCII character set.
- *-- NOTE: To use this routine properly, two things must
- *-- be done first:
- *-- PUBLIC n_rowpop, n_colpop
- *-- a Call to LocPop() should be made with a WHEN
- *-- clause in the "get". See example below.
- *-- Written for.: dBASE IV, 1.5
- *-- Rev. History: 12/28/1992 -- Original release
- *-- 01/27/1993 -- Modified (KJM) to cope with data entry
- *-- windows which includes restoring the active window
- *-- when done.
- *-- 06/30/1993 -- Added optional color parm.
- *-- Calls.......: LocPop() Indirectly. FUNCTION in PICKLIST.PRG
- *-- Called by...: Any (routine with a get)
- *-- Usage.......: DO Diacrit [with <cColor>]
- *-- Example.....: public n_rowpop, n_colpop && vital
- *-- @5,10 get cVar when LocPop(5,10) && vital (if no
- * -- && border, add ,0
- *-- on key label ALT-K DO DIACRIT && after 10)
- *-- read
- *-- on key label alt-k && release definition
- *-- Returns.....: keyboards character into current "get"
- *-- Parameters..: cColor = Optional, used to define the colors of the
- *-- popup (forg/back)
- *-- first pair = background/unselected/box
- *-- second pair = selected/highlighted
- *-----------------------------------------------------------------------
-
- parameters cColor
-
- private nRow, nCol, nRow2, nCol2, cReturn, cTemp1, cTemp2, cOldcol
- on key label alt-C ?? chr(7) && beep if user tries to call again ...
-
- *-- first things first, define where it's to display
- m->cWindow = window() && save current window if there is one
- activate screen
- m->nRow = m->n_rowpop && get values from public memvars
- m->nCol = m->n_colpop
-
- *-- bottom right corner of popup ...
- m->nCol2 = m->nCol + 5
- m->nRow2 = m->nRow + 10
-
- *-- deal with colors if there are any
- if pcount() > 0
- m->cOldcol = set("ATTRIBUTE")
- m->cTemp1 = colorbrk(m->cColor,1)
- m->cTemp2 = colorbrk(m->cColor,2)
- set color of message to &cTemp1.
- set color of box to &cTemp1.
- set color of highlight to &cTemp2.
- endif
-
- *-- define the popup
- define popup pDiacrit from m->nRow,m->nCol to m->nRow2,m->nCol2
- define bar 1 of pDiacrit prompt " "+chr(142)+" " && é
- define bar 2 of pDiacrit prompt " "+chr(143)+" " && è
- define bar 3 of pDiacrit prompt " "+chr(146)+" " && í
- define bar 4 of pDiacrit prompt " "+chr(131)+" " && É
- define bar 5 of pDiacrit prompt " "+chr(132)+" " && Ñ
- define bar 6 of pDiacrit prompt " "+chr(133)+" " && Ö
- define bar 7 of pDiacrit prompt " "+chr(134)+" " && Ü
- define bar 8 of pDiacrit prompt " "+chr(160)+" " && †
- define bar 9 of pDiacrit prompt " "+chr(145)+" " && ë
- define bar 10 of pDiacrit prompt " "+chr(144)+" " && ê
- define bar 11 of pDiacrit prompt " "+chr(136)+" " && à
- define bar 12 of pDiacrit prompt " "+chr(137)+" " && â
- define bar 13 of pDiacrit prompt " "+chr(138)+" " && ä
- define bar 14 of pDiacrit prompt " "+chr(130)+" " && Ç
- define bar 15 of pDiacrit prompt " "+chr(139)+" " && ã
- define bar 16 of pDiacrit prompt " "+chr(140)+" " && å
- define bar 17 of pDiacrit prompt " "+chr(141)+" " && ç
- define bar 18 of pDiacrit prompt " "+chr(161)+" " && °
- define bar 19 of pDiacrit prompt " "+chr(147)+" " && ì
- define bar 20 of pDiacrit prompt " "+chr(148)+" " && î
- define bar 21 of pDiacrit prompt " "+chr(149)+" " && ï
- define bar 22 of pDiacrit prompt " "+chr(162)+" " && ¢
- define bar 23 of pDiacrit prompt " "+chr(153)+" " && ô
- define bar 24 of pDiacrit prompt " "+chr(150)+" " && ñ
- define bar 25 of pDiacrit prompt " "+chr(129)+" " && Å
- define bar 26 of pDiacrit prompt " "+chr(151)+" " && ó
- define bar 27 of pDiacrit prompt " "+chr(163)+" " && £
- define bar 28 of pDiacrit prompt " "+chr(154)+" " && ö
- define bar 29 of pDiacrit prompt " "+chr(152)+" " && ò
- define bar 30 of pDiacrit prompt " "+chr(128)+" " && Ä
- define bar 31 of pDiacrit prompt " "+chr(165)+" " && •
- define bar 32 of pDiacrit prompt " "+chr(164)+" " && §
-
- *-- whatta we do with it?
- on selection popup pDiacrit deactivate popup
- activate popup pDiacrit
- m->cprompt = prompt()
-
- *-- Esc -> <-
- if lastkey() = 27 .or. lastkey() = 4 .or. lastkey() = 19
- m->cReturn = ""
- else
- m->cReturn = substr(m->cprompt,2,1) && get the actual character
- endif
-
- *-- remove from memory
- release popup pDiacrit
- if pcount() > 0
- do recolor with m->cOldcol
- endif
-
- *-- reactivate window if there was one ...
- if .NOT. isblank(m->cWindow)
- activate window &cWindow.
- endif
-
- *-- put into user's "get"
- keyboard m->cReturn
-
- *-- reset on KEY definition
- if pcount() > 0
- on key label alt-C do diacrit with "&cColor."
- else
- on key label alt-C do diacrit
- endif
-
- RETURN
- *-- EoP: Diacrit
-
- FUNCTION LocPop
- *-----------------------------------------------------------------------
- *-- Programmer..: Kenneth Chan (:>Zak<:) (CIS: 72662,1305)
- *-- Date........: 01/28/1993
- *-- Notes.......: Created for diacritical routine above, to determine
- *-- position of current "get", and then decide whether to
- *-- place upper left coordinates (in public memvars:
- *-- n_rowpop, n_colpop) of a popup.
- *-- Written for.: dBASE IV, 1.5
- *-- Rev. History: 12/25/1992 -- Original
- *-- 12/28/1992 -- Modified to deal with positioning if
- *-- get is to far to the right on the screen, and so on
- *-- (Ken Mayer).
- *-- 01/28/1993 -- Modified to handle windows on screen,
- *-- giving an absolute address. Requires user to provide
- *-- coordinates for upper left corner of window.
- *-- Calls.......: Vidrow() Function in SCREEN.PRG
- *-- Vidcol() Function in SCREEN.PRG
- *-- Called by...: Diacrit (Indirectly) Procedure in PICKLIST.PRG
- *-- Usage.......: LocPop(<nWidth>,<nLength>[,<nWborder>])
- *-- Example.....: @5,10 get cVar when LocPop(5,10)
- *-- Returns.....: logical true
- *-- Parameters..: nWidth = width of popup
- *-- nLength = length of popup (how many bars should
- *-- display on screen -- used to determine if
- *-- displaying above or below row() of get)
- *-- nWborder = OPTIONAL -- if there is no border we have
- *-- to back up one, so put a '0' in here if
- *-- there is no border, otherwise, ignore this
- *-- parameter.
- *-----------------------------------------------------------------------
-
- parameters nWidth,nLength, nWborder
- private cVar, nRow, nCol
-
- *-- get current "get"
- m->cVar = varread()
-
- *-- puts current position into column/row ... since cursor was just
- *-- placed into field (assuming called from WHEN clause), we are
- *-- always on the first character in the get ...
-
- m->nRow = Vidrow()
- m->nCol = Vidcol()
-
- if type("NWBorder") # "L" .and. m->nWborder = 0
- m->nRow = m->nRow - 1
- m->nCol = m->nCol - 1
- endif
-
- *-- add it all up, see if popup coordinates are off the screen
- *-- if so, we need to display the popup UNDER the get
- if m->nCol + (len(&cVar)+m->nWidth+1) > 79
- m->nRow = m->nRow + 1
- m->nCol = 79 - m->nWidth && put it right up against edge of screen
- else && otherwise, set column position
- m->nCol = m->nCol + len(&cVar.) + 1 && add length of memvar/get
- endif
-
- *-- now to see if we're going to go off the bottom of the screen
- *-- and deal with _that_ -- displaying popup ABOVE the get.
- m->nDisp = val(RIGHT(set("DISPLAY"),2)) && (EGAxx ...)
- if m->nRow + m->nLength + 5 => m->nDisp - 1 && check for bottom of
- m->nRow = m->nRow - m->nLength - 5 && screen
- endif
-
- if type("N_ROWPOP") = "U" .or. type("N_ROWPOP") = "L"
- public n_rowpop,n_colpop
- endif
- m->n_rowpop = m->nRow && set current position ...
- m->n_colpop = m->nCol
-
- RETURN .T.
- *-- EoF: LocPop()
-
- *-----------------------------------------------------------------------
- *-- Included below are any auxiliary routines needed for those above.
- *-----------------------------------------------------------------------
-
- FUNCTION USED
- *-----------------------------------------------------------------------
- *-- Programmer..: Ken Mayer (CIS: 71333,1030)
- *-- Date........: 02/28/1992
- *-- Notes.......: Created because the picklist routine by Malcolm Rubel
- *-- from DBA Magazine (11/91) calls a function that
- *-- checks to see if a DBF file is open ...
- *-- Written for.: dBASE IV, 1.5
- *-- Rev. History: 05/15/1992 -- Original
- *-- 02/08/1993 -- Discovered (thanks to Jay, and then
- *-- Malcolm) a much simpler way to do this ...
- *-- Called by...: Any
- *-- Calls.......: none
- *-- Usage.......: used("<cFile>")
- *-- Example.....: if used("Library")
- *-- select library
- *-- else
- *-- select select()
- *-- use library
- *-- endif
- *-- Returns.....: Logical (.t. if file is in use, .f. if not)
- *-- Parameters..: cFile = file to check for
- *-----------------------------------------------------------------------
-
- parameters cFile
-
- RETURN (select(m->cFile) # 0)
- *-- EoF: used()
-
- FUNCTION VidRow
- *-----------------------------------------------------------------------
- *-- Programmer..: Ken Mayer (CIS: 71333,1030)
- *-- Date........: 01/28/1993
- *-- Notes.......: Calls VDcursor.BIN (David Frankenbach, CIS:
- *-- 72147,2635) to return the ABSOLUTE position of the
- *-- current ROW on the screen, despite any active
- *-- windows, etc. This is based on original routines by
- *-- David Frankenbach, but includes the load/release in
- *-- one routine, rather than requiring three functions to
- *-- perform this ...
- *-- ***************************
- *-- ** REQUIRES VDcursor.BIN **
- *-- ***************************
- *-- Written for.: dBASE IV, 1.5
- *-- Rev. History: 01/28/1993 -- Original release
- *-- Calls.......: VDcursor.BIN
- *-- Called by...: Any
- *-- Usage.......: Vidrow()
- *-- Example.....: ?Vidrow()
- *-- Returns.....: Numeric ROW position for current row on screen
- *-- Parameters..: none
- *-----------------------------------------------------------------------
-
- private cX
-
- m->cX = space(2) && define argument memvar
- load vdcursor && load the .BIN file
- call vdcursor with m->cX && call it with the memvar
- release module vdcursor && release from memory
-
- RETURN (asc(substr(m->cX,2))-1) && return the value of the absolute
- *-- && cursor position
- *-- EoF: Vidrow()
-
- FUNCTION VidCol
- *-----------------------------------------------------------------------
- *-- Programmer..: Ken Mayer (CIS: 71333,1030)
- *-- Date........: 01/28/1993
- *-- Notes.......: calls VDcursor.BIN (David Frankenbach, CIS:
- *-- 72147,2635) to return the ABSOLUTE position of the
- *-- current COLUMN on the screen, despite any active
- *-- windows, etc. This is based on original routines by
- *-- David Frankenbach, but includes the load/release in
- *-- one routine, rather than requiring three functions to
- *-- perform this ...
- *-- ***************************
- *-- ** REQUIRES VDcursor.BIN **
- *-- ***************************
- *-- Written for.: dBASE IV, 1.5
- *-- Rev. History: 01/28/1993 -- Original release
- *-- calls.......: VDcursor.BIN
- *-- called by...: Any
- *-- Usage.......: Vidcol()
- *-- Example.....: ?Vidcol()
- *-- Returns.....: Numeric COLUMN position for current Col on screen
- *-- Parameters..: none
- *-----------------------------------------------------------------------
-
- private cX
-
- m->cX = space(2) && define argument memvar
- load vdcursor && load the .BIN file
- call vdcursor with m->cX && call it with the memvar
- release module vdcursor && release from memory
-
- RETURN (asc(subst(m->cX,1))-1) && return the value of the absolute
- *-- && cursor position
- *-- EoF: Vidcol()
-
-
- *-----------------------------------------------------------------------
- *-- End of File: PICKLIST.PRG
- *-----------------------------------------------------------------------
-